package com.example.springboot.controller;

import com.example.springboot.common.Result;
import com.example.springboot.entity.feedbacks;
import com.example.springboot.service.FeedbackService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@CrossOrigin(origins = "http://localhost:7070")
@RestController
@RequestMapping("/Feedback")
public class FeedbackController {
    @Autowired
    private FeedbackService feedbackService;

    @GetMapping("/selectAll")
    public Result selectAll() {
        List<feedbacks>  feedbacksList =feedbackService.selectAll();
        return Result.success(feedbacksList);
    }

    @DeleteMapping("/delete/{feedback_id}")
    public String deleteFeedback(@PathVariable int feedback_id) {
        feedbackService.deleteFeedback(feedback_id);
        return "User record deleted successfully!";
    }

    @PutMapping("/edit")
    public Result editFeedback(@RequestBody feedbacks feedbacks) {
        feedbackService.editFeedback(feedbacks);
        return Result.success("编辑成功");
    }
}
